#include "mainwindow.h"
#include "ui_mainwindow.h"
#include<QMessageBox>
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    ui->port_2->setText("8899");
    server=NULL;
    socket=NULL;
    server=new QTcpServer(this);
    connect(server,&QTcpServer::newConnection,this,[=](){
        socket=server->nextPendingConnection();
        MyServer *socket11=new MyServer(socket);
        socket11->start();
        connect(socket11,&MyServer::over,this,[=](){
            socket11->exit();
            socket11->wait();
            socket11->deleteLater();
            QMessageBox::information(this,"文件接收","文件接收完毕");

        });
    });

}

MainWindow::~MainWindow()
{
    delete ui;
}

//启动监听

void MainWindow::on_setlisten_clicked()
{
    quint16 port=ui->port_2->text().toInt();
    server->listen(QHostAddress::Any,port);

}


